package com.zt.csp.shorturl.utils;

import com.zt.csp.shorturl.dto.ServiceResult;
import org.springframework.util.StringUtils;

/**
 * 字符串检查
 * Created by zt on 2018/4/17 0017
 */
public class StringChecker {
    public static ServiceResult longUrlCheck(String longUrl) {
        if (StringUtils.isEmpty(longUrl)) {
            return ServiceResult.failed(10005, "长链接为空，请输入长链接");
        }

        if (!longUrl.startsWith("http://") && !longUrl.startsWith("https://")) {
            return ServiceResult.failed(10006, "链接必须以http://开头或者以https://开头");
        }

        return ServiceResult.ok(longUrl);
    }
}
